import { GET, POST, PUT, DELETE } from '@/utils/request'
import { updateProductParams } from '../types/product'
import { typePaging } from '../types/index'

/**
 * 加载项目商品
 */
export const getProducts = (params:typePaging) => GET(`/product/paging/list`, params)

/**
 * 根据id加载单个商品
 * @param id 项目id
 */
export const getProduct = (id:string) => GET(`/product/${ id }`)

/**
 * 添加商品
 */
export const addProduct = () => POST(`/product/create`)

/**
 * 删除商品
 */
export const delProduct = (id:string) => DELETE(`/product/${ id }`)

/**
 * 更新商品
 */
export const updateProduct = (id:string, data:updateProductParams) => PUT(`/product/${ id }`, data)

/**
 * 上传商品图片
 */
export const uploadProductImg = (formData:FormData) => POST(`/upload/product-cover`, formData, { headers: {
  'Content-Type': 'multerpart/form-data'
}})
